{% extends 'wxchat/wxbase.html' %}{% load static %}
{% block container %}
<div class="page">
    {% include "shopping/include/myheader.html" %}
    <div class="page_body">
       <div class="weui-panel weui-panel_access">
            <div class="weui-panel__hd">
                <div class="weui-flex">
                    <div><a href="{% url 'shopping-list' %}"><i class="icon iconfont icon-jiantou3 gray" ></i></a></div>
                    <div class="weui-flex__item" style="text-align: center;"><span class="detail_title">我的支付订单</span></div>
                     <div ><a href="{% url 'shopping-list' %}?next={{ request.get_full_path }}"><i class="icon iconfont icon-shangcheng10 pink r" ></i></a></div>
                 </div>
            </div>
            <div class="weui-panel__bd">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <p><i class="icon iconfont icon-shangcheng2" ></i> {{ project_name }}</p>
                    </div>
                </div>
                {% if order %}
                    {% for orderItem in order.items.all %}
                        <div class="weui-media-box weui-media-box_appmsg" style="background-color: #fafafa">
                            {% if orderItem.goods.images %}
                            <div class="weui-media-box__hd">
                                 <img class="weui-media-box__thumb" src="{{orderItem.goods.images.url }}" alt="">
                            </div>
                            {% endif %}
                            <div class="weui-media-box__bd">
                                <h4 class="weui-media-box__title">{{ orderItem.goods.name }}</h4>
                                <ul class="weui-media-box__info ">
                                    <li class="weui-media-box__info__meta sub_title">¥ {{ orderItem.goods.price }}</li>
                                    <li class="weui-media-box__info__meta r" style="color: #977a7a;" >
                                        x{{ orderItem.quantity }}
                                    </li>
                                    <li class="weui-media-box__info__meta r" style="color: #c9302c;">
                                        会员送:<span  id="card">{{ orderItem.goods.diff_price }}</span><i class="icon iconfont icon-youhuiquan1 benefits_card"></i>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    {% endfor %}
                    <div class="weui-cell cell-end">
                        <div class="weui-cell__bd color_red"  ><B>{% if order.status == 1 %} 已支付{% endif %}</B></div>
                        <div class="weui-cell__ft " style="color:#000000" >
                            {% if is_member == 1 %}
                            <p>共 {{ order.get_total_count }} 件商品, 付款金额<B> ¥{{ order.get_member_total_cost }}</B></p>
                            {% else %}
                             <p>共 {{ order.get_total_count }} 件商品, 付款金额 ¥{{ order.get_total_cost }}</p>
                            {% endif %}
                            <p>订单编号:{{ order.out_trade_no }}</p>
                        </div>
                    </div>
                    <div class="weui-cell cell-end">
                        <div class="weui-cell__bd color_red"  ><B>{% if order.is_mail %} 已发货{% endif %}</B></div>
                        <div class="weui-cell__ft " style="color:#000000" >
                            <p>姓名:{{ order.username }}  联系电话:{{ order.telnumber }}</p>
                        </div>
                    </div>
                    <div class="weui-cell cell-end">
                        <p>发货地址:{{ order.detailinfo }}</p>
                     </div>
                   {% if company_member %}
                    <a href="javascript:;" class="weui-btn weui-btn_primary" id="send_confirm" data-item="{{order.out_trade_no }}" data-id="{{ order.is_mail }}">发货确认</a>
                   {% endif %}
                {% endif %}
                <!--定制食品订单-->
                {% if dogorder %}
                    <div class="weui-media-box weui-media-box_appmsg" style="background-color: #fafafa">
                        <div class="weui-media-box__bd">
                            <h4 class="weui-media-box__title">{{ dogorder.product_detail }}</h4>
                            <ul class="weui-media-box__info ">
                                <li class="weui-media-box__info__meta sub_title">¥ {{ dogorder.price }}</li>
                                <li class="weui-media-box__info__meta r" style="color: #977a7a;" >
                                    x{{ dogorder.goods_nums }}
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="weui-cell cell-end">
                        <div class="weui-cell__bd color_red"  ><B>{% if dogorder.status == 1 %} 已支付{% endif %}</B></div>
                        <div class="weui-cell__ft " style="color:#000000" >
                            <p>共 {{ dogorder.goods_nums }} 件商品, 付款金额<B> ¥{{ dogorder.total_fee }}</B></p>
                            <p>订单编号:{{ dogorder.out_trade_no }}</p>
                        </div>
                    </div>
                {% endif %}
            </div>

        </div>
    </div>
</div>


{% endblock container %}
{% block bottomjs %}

    {{ block.super }}
    {% if company_member %}
    <script>
        $(function(){
            $("#send_confirm").on("click",function(){
                let is_mail = $(this).attr("data-id");
                if(is_mail == "True") return;
                let out_trade_no = $(this).attr("data-item");
                var params ={
                  out_trade_no: out_trade_no,
                  csrfmiddlewaretoken:'{{ csrf_token }}',
                  action:"confirm",
                }
               $.ajax({
                  type: 'POST',
                  url: '{% url "my-order-list" %}',
                  dataType: 'json',
                  data: params,
                  timeout: 5000,
                  success: function(data){
                    if(data.success == "true"){
                        weui.alert('发货确认成功!', function(){
                            window.location.href = ('{% url "my-order-list" %}?out_trade_no=' + out_trade_no);
                        });
                    }
                    else{
                        weui.alert('发货确认失败!');
                    }
                  },
                  error: function(error){
                      window.location.href = "{% url 'shopping-list' %}";
                  }
                });
            });
        })
    </script>
    {% endif %}


{% endblock bottomjs %}
